package container;

import java.util.ArrayList;
import java.util.HashMap;

import utgame.UtMessage;

/**
 * Created by xueal on 2018/1/17.
 */

public class ChatManager {

    private static final ChatManager single = new ChatManager();

    public static ChatManager getInstance() {
        return single;
    }

    private HashMap<String, ArrayList<String>> mPlayerChatMap = new HashMap<>();     // 别人给自己发的未读消息

//    private HashMap<String, ArrayList<Msg>> mChatLogMap = new HashMap<>();           // 别人和我的聊天记录

    private UtMessage.MS_OfflineChat offlineChat = null;                             // 别人发给我的离线聊天记录

    public boolean isHomeReload = false;


    public UtMessage.MS_OfflineChat getOfflineChat() {
        return offlineChat;
    }
    public void setOfflineChat(UtMessage.MS_OfflineChat offlineChat) {
        this.offlineChat = offlineChat;
    }

    public void addChat(String name, String content){
        if (mPlayerChatMap.get(name) == null){
            mPlayerChatMap.put(name, new ArrayList<String>());
        }
        ArrayList<String> chatList = mPlayerChatMap.get(name);
        chatList.add(content);
    }
    public ArrayList<String> getChat(String name){
        return mPlayerChatMap.get(name);
    }
    public void clearChat(String name){
        mPlayerChatMap.remove(name);
    }

    public void destroy(){
        mPlayerChatMap.clear();
        offlineChat = null;
    }

//    public void addChatLog(String name, Msg msg){
//        if (mChatLogMap.get(name) == null){
//            mChatLogMap.put(name, new ArrayList<Msg>());
//        }
//        ArrayList<Msg> msgArrayList = mChatLogMap.get(name);
//        msgArrayList.add(new Msg(msg.getContent(), msg.getType()));
//    }
//    public ArrayList<Msg> getChatLog(String name){
//        if (mChatLogMap.get(name) == null){
//            mChatLogMap.put(name, new ArrayList<Msg>());
//        }
//        return mChatLogMap.get(name);
//    }
}
